//4 encoders correspondent to 4 external interrupts are used: 7,2,3,6
#ifndef	_FREERTOS_ENCODER_H_
#define _FREERTOS_ENCODER_H_


//declare variable used
extern int volatile	L_ecdr_vbuf;
extern int volatile	R_ecdr_vbuf;
extern int volatile	L_ecdr_sbuf;
extern int volatile	R_ecdr_sbuf;
//MACROs
//input: the number of encoder's pulse (L_ecdr_vbuf,R_ecdr_vbuf)
// called in a pacticular period
#define GET_VELOCITY(L_velocity,R_velocity){ \
	L_velocity = (L_ecdr_vbuf)/20; \
	R_velocity = (R_ecdr_vbuf)/20; \
	L_ecdr_vbuf = 0; \
	R_ecdr_vbuf = 0;}
#define	RESET_DISTANCE()	{\
	L_ecdr_sbuf = 0;\
	R_ecdr_sbuf = 0;}
void get_velocity(int *L_velocity,int *R_velocity,int old_L, int old_R);
void init_encoder(void);
#endif //_FREERTOS_ENCODER_H_
